package com.guli.gulimall.third;

import com.aliyun.oss.OSS;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

@SpringBootTest
@RunWith(SpringRunner.class)
public class ThirdDemo {

    @SuppressWarnings("all")
    @Autowired
    private OSS oss;

    @Value("${alibaba.cloud.access-key}")
    private String accessKey;

    @Value("${alibaba.cloud.secret-key}")
    private String secretKey;

    @Value("${alibaba.cloud.oss.endpoint}")
    private String endpoint;

    @Value("${alibaba.cloud.oss.bucket-name}")
    private String bucketName;

    @Test
    public void ossTest(){
        try {
            oss.putObject(bucketName,"456.jpg",new FileInputStream("C:\\Users\\ASUS\\Pictures\\Saved Pictures\\23.jpg"));
            System.out.println("springboot版本的文件上传");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

    }
}
